package com.deft.design.flyweight;

import java.time.LocalDateTime;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Hide丶love
 * @date 2022/05/06
 **/
public class ActivityFactory {

    static Map<Long, Activity> activityMap = new ConcurrentHashMap<>();

    public static Activity getActivity(Long id) {
        Activity activity = activityMap.get(id);
        if (activity == null) {
            activity = new Activity();
            activity.setId(10001L);
            activity.setName("图书嗨乐");
            activity.setDesc("图书优惠券分享激励分享活动第二期");
            activity.setStartTime(LocalDateTime.now());
            activity.setStopTime(LocalDateTime.now());
            activityMap.put(id, activity);
        }
        return activity;
    }
}
